import argparse

import command


def git_push():
    parser = argparse.ArgumentParser(description='git 推送更新')
    parser.add_argument('-s', '--source', nargs='?', default='feature/zx', help='源分支')
    parser.add_argument('-t', '--target', nargs='?', default='dev', help='目标分支')
    args, unknown_args = parser.parse_known_args()
    source = args.source
    target = args.target
    if len(unknown_args) > 0:
        source = unknown_args[0]

    if len(unknown_args) > 1:
        source = unknown_args[0]
        target = unknown_args[1]
    command_line = [
        "git push",
        (f"git -c credential.helper=wincred -c core.quotepath=false -c log.showSignature=false push "
         f"--progress --porcelain origin refs/heads/{source}:{target}")
    ]
    command.exe_command(command_line)


if __name__ == '__main__':
    git_push()
